home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / X11R4 / cmds / X / ddx / sprite.X11R3 / hdr / pr_impl_util.h < prev    next >
Encoding:
C/C++ Source or Header  |  1989-11-03  |  3.8 KB  |  188 lines

  1. /* @(#)pr_impl_util.h 1.9 89/04/28 SMI */
  2.  
  3. /*
  4.  * Copyright 1987-1989 Sun Microsystems,  Inc.
  5.  */
  6.  
  7. /* 
  8.  * Pixrect implementation utilities 
  9.  */
  10.  
  11. #ifndef    pr_impl_util_DEFINED
  12. #define    pr_impl_util_DEFINED
  13.  
  14. /* Reiser cpp concatenation macros */
  15. #ifndef _CAT
  16. #undef    _IDENT
  17. #define _IDENT(x)    x
  18. #define    _CAT(a,b)    _IDENT(a)b
  19. #endif
  20.  
  21. /*
  22.  * code selection macros
  23.  */
  24. #define    IFTRUE(a,b) a
  25. #define IFFALSE(a,b) b
  26.  
  27. /* and together multiple options */
  28. #define    IFAND IFAND2
  29. #define IFAND2(opt1,opt2,a,b) opt1(opt2(a,b),b)
  30. #define IFAND3(opt1,opt2,opt3,a,b) opt1(opt2(opt3(a,b),b),b)
  31. #define IFAND4(opt1,opt2,opt3,opt4,a,b) opt1(opt2(opt3(opt4(a,b),b),b),b)
  32. #define IFAND5(opt1,opt2,opt3,opt4,opt5,a,b) \
  33.         opt1(opt2(opt3(opt4(opt5(a,b),b),b),b),b)
  34. #define IFAND6(opt1,opt2,opt3,opt4,opt5,opt6,a,b) \
  35.         opt1(opt2(opt3(opt4(opt5(opt6(a,b),b),b),b),b),b)
  36.  
  37. #ifdef KERNEL
  38. #define    IFKERNEL IFTRUE
  39. #else
  40. #define    IFKERNEL IFFALSE
  41. #endif
  42.  
  43. /*
  44.  * lint garbage
  45.  */
  46. #ifdef lint
  47.  
  48. #define    IFLINT    IFTRUE
  49.  
  50. int _ZERO_;    /* "constant in conditional context" workaround */
  51. #define    _ONE_    (!_ZERO_)
  52. int _loop;    /* "_loop redefinition hides earlier one" */
  53.  
  54. #else lint
  55.  
  56. #define    IFLINT    IFFALSE
  57.  
  58. #define    _ZERO_ 0
  59. #define    _ONE_ 1
  60.  
  61. #endif lint
  62.  
  63. /*
  64.  * portability aids
  65.  */
  66. #ifdef mc68000
  67.  
  68. #define    IF68000    IFTRUE
  69.  
  70. typedef    caddr_t    INT_T;        /* pseudo-integer type (address register) */
  71. typedef u_long    PTR_T;        /* pseudo-pointer type (data register) */
  72. typedef    short    LOOP_T;        /* loop variable (for dbra loops) */
  73.  
  74. #define    LOOP_DECR(var)    (--(var) != -1)
  75.  
  76. #else mc68000
  77.  
  78. #define IF68000    IFFALSE
  79.  
  80. typedef    int    INT_T;
  81. typedef caddr_t    PTR_T;
  82. typedef    int    LOOP_T;
  83.  
  84. #define    LOOP_DECR(var)    (--(var) >= 0)
  85.  
  86. #endif mc68000
  87.  
  88. #ifdef sparc
  89. #define    IFSPARC    IFTRUE
  90. #else
  91. #define    IFSPARC    IFFALSE
  92. #endif
  93.  
  94. /* true if we can make 32 bit accesses on 16 bit boundaries */
  95. #ifndef    SHORT_ALIGN
  96. #define    SHORT_ALIGN    (!defined(sparc))
  97. #endif
  98.  
  99. #if SHORT_ALIGN
  100. #define    IFSHORT_ALIGN    IFTRUE
  101. #else
  102. #define    IFSHORT_ALIGN    IFFALSE
  103. #endif
  104.  
  105.  
  106. #ifndef LITTLE_ENDIAN
  107. #define    LITTLE_ENDIAN    defined(i386)
  108. #endif
  109.  
  110. #if LITTLE_ENDIAN
  111. #define    ENDIAN    IFTRUE
  112. #else
  113. #define    ENDIAN    IFFALSE
  114. #endif
  115.  
  116. /*
  117.  * SunOS release number
  118.  * warning: these tests are fragile
  119.  */
  120. #if defined(sun) && !defined(SUNOS)
  121. #ifdef _sys_types_h
  122. #define    SUNOS    41
  123. #else _sys_types_h
  124. #ifdef NFDBITS
  125. #define    SUNOS    40
  126. #else NFDBITS
  127. #define    SUNOS    35
  128. #endif NFDBITS
  129. #endif _sys_types_h
  130. #endif
  131.  
  132. #if SUNOS >= 40
  133. #define    IFSUNOS4    IFTRUE
  134. #else
  135. #define    IFSUNOS4    IFFALSE
  136. #endif
  137.  
  138. #if SUNOS >= 41
  139. #define    IFSUNOS41    IFTRUE
  140. #else
  141. #define    IFSUNOS41    IFFALSE
  142. #endif
  143.  
  144.  
  145. /*
  146.  * misc. macros
  147.  */
  148.  
  149. /* statement macro */
  150. #define    _STMT(op)    do { op } while (_ZERO_)
  151.  
  152. /* loop macros */
  153. #define    PR_LOOPVP(var, op)     do { op; } while (LOOP_DECR(var))
  154. #define    PR_LOOPV(var, op)    _STMT(while (LOOP_DECR(var)) { op; })
  155. #define    PR_LOOPP(count, op)    _STMT( \
  156.     IFLINT(, register LOOP_T) _loop = (count); PR_LOOPVP(_loop, op);)
  157. #define    PR_LOOP(count, op)    _STMT( \
  158.     IFLINT(, register LOOP_T) _loop = (count); PR_LOOPV(_loop, op);)
  159.  
  160. /* pointer manipulation */
  161. #define    PTR_ADD(p, incr)    ((caddr_t) (p) + (incr))
  162. #define    PTR_INCR(type, p, incr)    (p = (type) ((caddr_t) (p) + (incr)))
  163.  
  164. /* unshifted pixrect op codes */
  165. #define    PIX_OPSRC    (12)
  166. #define    PIX_OPDST    (10)
  167. #define    PIX_OPNOT(op)    ((op) ^ 15)
  168. #define    PIX_OPCLR    (0)
  169. #define    PIX_OPSET    (15)
  170.  
  171. /* extract color and op code fields */
  172. #define    PIXOP_COLOR(op)    ((op) >> 5)
  173. #define    PIXOP_OP(op)    ((op) >> 1 & 15)
  174.  
  175. /* reverse video src or dst */
  176. #define    PIX_OP_REVERSESRC(op)    (((op) & 3) << 2 | (op) >> 2 & 3)
  177. #define    PIX_OP_REVERSEDST(op)    ((~(op) & 5) << 1 | ~(op) >> 1 & 0x5)
  178.  
  179. /* determine if op needs src or dst */
  180. #define    PIX_OP_NEEDS_SRC(op)    (((op) >> 2 ^ (op)) & 3)
  181. #define    PIX_OP_NEEDS_DST(op)    (((op) >> 1 ^ (op)) & 5)
  182.  
  183. /* misc. data types */
  184. typedef    short    MPR_T;        /* type used for memory pixrect data */
  185. typedef    u_short    UMPR_T;        /* unsigned equivalent of MPR_T */
  186.  
  187. #endif    pr_impl_util_DEFINED
  188.